<template>
  <el-card class="tags-main" shadow="never">
    <p class="tags-main-title">标签 - {{ tags.length }}</p>
    <ul class="tags-main-list">
      <li v-for="tag of tags" :key="tag.id" class="tags-item">
        <router-link
          :to="{
            name: 'PublicPage',
            params: { menuName: 'tags', label: tag.name },
          }"
          class="tag-link"
          :style="{
            color: tag.color,
            fontSize: (tag.weight / 100) * 1.2 + 'rem',
          }"
        >
          {{ tag.name }}
        </router-link>
      </li>
    </ul>
  </el-card>
</template>

<script>
import $api from "$api/tags";
export default {
  name: "TagsMain",
  data() {
    return {
      tags: [],
    };
  },
  mounted() {
    this.getTags();
  },
  methods: {
    getTags() {
      $api.getTags().then((res) => {
        if (res.status === 200) {
          this.tags = res.data;
        }
      });
    },
  },
};
</script>

<style lang="stylus" scoped>
.tags-main-title {
  text-align: center;
  font-size: 0.3rem;
  padding: 0.1rem;
}

.tags-main-list {
  line-height: 2;
}

.tags-item {
  padding: 0 0.08rem;
  display: inline-block;
  transition: all 0.3s;
}

.tags-item:hover {
  transform: scale(1.1);

  a {
    color: var(--colorLevel1) !important;
  }
}
</style>